﻿using System;
using System.Collections.Generic;
using MovieDB.Data.Entities;
using MovieDB.Data.Repositories;

namespace MovieDB.Business
{
    public class ReferenceDataManager : IReferenceDataManager
    {
        private readonly IRepository<Category> _categoryRepository;

        public ReferenceDataManager(IRepository<Category> catRepository)
        {
            _categoryRepository = catRepository;
        }

        public List<Category> GetAllCategories()
        {
            return _categoryRepository.FindManyBy(x => true);
        }

        public Category GetCategoryById(int id)
        {
            return _categoryRepository.FindById(id);
        }

        public void SaveCategory(Category category)
        {
            _categoryRepository.Save(category);
        }

        public void DeleteCategoryById(int id)
        {
            var cat = _categoryRepository.FindById(id);
            _categoryRepository.Delete(cat);
        }
    }
}
